package gui;

import java.awt.Color;
import java.awt.GridBagLayout;
import javax.swing.JPanel;
import java.awt.Dimension;
import javax.swing.JTabbedPane;
import java.awt.Rectangle;
import java.util.HashMap;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;

import code.Language;
import code.Settings;

public class CertificateMain extends JPanel {
	
	Color c= new Color(0x80, 0x80, 0xFF);
	private HashMap labels;

	private static final long serialVersionUID = 1L;
	private JTabbedPane jTabbedPane = null;
	private JPanel jpanel;
	ATOCOmain atocoframe;
	private Settings s;

	/**
	 * This is the default constructor
	 */
	public CertificateMain(ATOCOmain atocoframe) {
		super();
		Language l = new Language();
		s= new Settings();
		labels = l.changeLanguage((String) s.global.get("language"), "CertificateMain", (String) s.global.get("installPath"));

		this.atocoframe=atocoframe;
		initialize();
		this.setPreferredSize( new Dimension( 400, 550 ) );
		System.out.println("CertificateMain --> atocoframe: "+ this.atocoframe);
		
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(766, 476);
		this.setLayout(null);
		this.add(getJTabbedPane(), null);
	}

	/**
	 * This method initializes jTabbedPane	
	 * 	
	 * @return javax.swing.JTabbedPane	
	 */
	private JTabbedPane getJTabbedPane() {
		
			jTabbedPane = new JTabbedPane();
			jTabbedPane.setBounds(new Rectangle(5, 4, 815, 520));
			
				jpanel= new CertificatePersonnel(atocoframe);
			System.out.println("aa");
			jTabbedPane.addTab((String) labels.get("tab1"), null, jpanel, null);
			jTabbedPane.addTab((String) labels.get("tab2"), null, new CertificateCA(atocoframe), null);
			//jTabbedPane.addTab("CA Mode", null);
			jTabbedPane.setSelectedIndex(0);
			jTabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
				public void stateChanged(javax.swing.event.ChangeEvent e) {
					if(jTabbedPane.getSelectedIndex()==0)
					{
						System.out.println(jTabbedPane.getSelectedIndex());
						jpanel= new CertificatePersonnel(atocoframe);
						refresh();
					}
					else if(jTabbedPane.getSelectedIndex()==1)
					{
						System.out.println(jTabbedPane.getSelectedIndex());
						jpanel= new CertificateCA(atocoframe);
						System.out.println(jpanel);
						refresh();
					}
				}
			});
		
		return jTabbedPane;
	}

	private void refresh(){
		this.validate();
		System.out.println("refresh yaptim: "+jpanel );
	}


}  //  @jve:decl-index=0:visual-constraint="10,10"
